<?php

namespace Member\Controller;

/**
 * AdvertisingContent 控制器类
 *
 * @since 1.0 <2015-11-7> SoChishun <14507247@qq.com> Added.
 */
class AdvertContent extends AppbaseController {

    public function index($ad_code = '') {
        $mContent = new \XWAM\Model\AdvertContentModel();
        $list = $mContent->where(array('advert_code' => $ad_code))->select();
        $this->assign('list', $list);
        $this->assign('ad_code', $ad_code);
        $this->display();
    }

    function edit($id = 0, $ad_code = '') {
        $data = array();
        $adv = array();
        $mAdvert = new \XWAM\Model\AdvertModel();
        $adv = $id ? $mAdvert->find($id) : $mAdvert->where(array('ad_code' => $ad_code))->find();
        if ($id) {
            $mContent = new \XWAM\Model\AdvertContentModel();
            $data = $mContent->find($id);
        } else {
            $data['advert_code'] = $ad_code;
        }
        $this->assign('data', $data);
        $this->assign('adv', $adv);
        $this->display();
    }

    function editSave() {
        $mContent = new \XWAM\Model\AdvertContentModel();
        $result = $mContent->saveContent();
        $this->dialogJump($result['status'], $result['info']);
    }

    function delete($id = '') {
        $mContent = new \XWAM\Model\AdvertContentModel();
        $result = $mContent->deleteContent($id);
        $this->ajaxReturn($result);
    }

    function changeSort($id, $sort) {
        $mContent = new \XWAM\Model\AdvertContentModel();
        $this->ajaxReturn($mContent->changeSort($id, $sort));
    }

}
